#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;

vector<int>arr = { 5,4,3,6,1,2 };

void quicksort(int left,int right){
	if (left >= right) {
		return;
	}
	int i = left, j = right, base = arr[left];
	while (i < j) {
		while (arr[j] >= base && i < j) {
			j--;
		}
		while (arr[i] <= base && i < j) {
			i++;
		}
		if (i < j) {
			swap(arr[i], arr[j]);
		}
	}
	arr[left] = arr[i];
	arr[i] = base;
	quicksort(left, i - 1);
	quicksort(i + 1, right);
}

int main() {
	int length = arr.size();
	cout << "原先的顺序为：";
	for (int i = 0; i < length; i++) {
		cout << arr[i] << ' ';
	}
	cout << endl;
	quicksort(0, length - 1);
	cout << "排序后的顺序为：";
	for (int i = 0; i < length; i++) {
		cout << arr[i] << ' ';
	}
	return 0;
}
